import type { WorkingHours } from '@/api/base/workCalendar/workingHours/model/type';

//''站位勿删
export const dayMap = ['', '周一', '周二', '周三', '周四', '周五', '周六', '周日'];

/**
 * @: 工作时段渲染方法
 */
export const handleHoursRender = (row: WorkingHours) => {
    let str = '';
    for (let i = 1; i <= 4; i++) {
        str += handleHours(i + '', row);
    }
    return str;
};
/**
 * @: 工作时段处理字段
 */
const handleHours = (key: string, target: WorkingHours) => {
    if (target['start' + key]) return ` ${target['start' + key]}-${target['end' + key]}`;
    return '';
};

/**
 * @: 处理后的表格数据类型
 */
export interface TData {
    [key: string]: string | [string, string] | undefined;
    grade1: [string, string];
    grade2: [string, string];
    grade3: [string, string];
    grade4: [string, string];
    id: string;
    name: string;
}

/**
 * @: 初始化 top-table 数据
 */
export const initTopTableData = () => {
    return [
        { workingDay: 1, periodId: 0, periodDesc: '' },
        { workingDay: 2, periodId: 0, periodDesc: '' },
        { workingDay: 3, periodId: 0, periodDesc: '' },
        { workingDay: 4, periodId: 0, periodDesc: '' },
        { workingDay: 5, periodId: 0, periodDesc: '' },
        { workingDay: 6, periodId: 0, periodDesc: '' },
        { workingDay: 7, periodId: 0, periodDesc: '' }
    ];
};
